package ee.database;

import ee.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService {
  @Resource(name = "jdbc")
  private JdbcTemplate jdbcTemplate;

  public User getUser(String username) {
    return null;
  }

  public void saveUser(User user) {
      String sql = "INSERT INTO USERS (firstname, lastname, username, email, password) VALUES " +
        "('" + user.getFirstname() + "'," +
        "'" + user.getLastname() + "'," +
        "'" + user.getUsername() + "'," +
        "'" + user.getEmail() + "'," +
        "'" + user.getPassword() + "');";
      jdbcTemplate.execute(sql);
  }
}
